#pragma once
#ifdef LIT_OGRE_SUPPORT

#ifndef __PHYSICS__MANAGER__INCLUDED__HH__
#define __PHYSICS__MANAGER__INCLUDED__HH__

#include <LitSingleton.hpp>
#include "LitPhysicsWorld.h"
#include "LitPhysicsDebug.h"
#include "LitCoreComponent.h"

namespace Lit
{
	class LIT_API PhysicsManager : public CoreComponent
	{
	public:
		typedef std::map<String, Physics::WorldPtr> WorldMap;
		typedef	Physics::World				World;
		typedef Physics::WorldPtr			WorldPtr;
		typedef Physics::Body				Body;
		typedef Physics::BodyPtr			BodyPtr;
		typedef Physics::CollisionShape		CollisionShape;
		typedef Physics::CollisionShapePtr	CollisionShapePtr;

		static const String DEFAULT_WORLD_NAME;
	protected:
		WorldMap	mWorlds;
		bool		mPause;

	public:
		PhysicsManager(void);
		~PhysicsManager(void);

		Type type() const{ return COM_PHYSICSMANAGER;	} 

		void initialise( const OgreDetails &details);
		bool renderOneFrame( float dt );
		void shutdown();
		
		bool isPaused() const;
		void setPaused( bool state );

		Physics::WorldPtr createWorld( const String &name = DEFAULT_WORLD_NAME, Physics::PlatformOptimisation optimis = Physics::PO_NONE, Physics::SolverModel solver = Physics::SM_ITERATIVE_SIMPLE, const Lit::AABB& dimensions = Lit::AABB::BOX_INFINITE );
		bool hasWorld( const String &name ) const;

		Physics::WorldPtr& getWorld( const String &name = DEFAULT_WORLD_NAME );
		const Physics::WorldPtr& getWorld( const String &name = DEFAULT_WORLD_NAME ) const;

		void destroyWorld( WorldPtr world );
		void destroyWorld( const String &name = DEFAULT_WORLD_NAME  );

		void clearWorld( WorldPtr world );
		void clearWorld( const String &name = DEFAULT_WORLD_NAME  );

		void destroyWorlds( );
		void clearWorlds( );
	};
};

#endif

#endif